package com.cardbaobao.cardbabyclient.ui.adapter;
import android.content.Context;
import android.view.View;

import com.cardbaobao.cardbabyclient.R;
import com.cardbaobao.cardbabyclient.ui.adapter.base.CommonRecyclerAdapter;
import com.cardbaobao.cardbabyclient.ui.adapter.base.CommonRecyclerHolder;
import com.cardbaobao.cardbabyclient.callback.RecycleItemClickedCallback;
import com.cardbaobao.cardbabyclient.model.BusinessClass;
import com.cardbaobao.cardbabyclient.utils.ImageLoaderUtil;
import com.cardbaobao.cardbabyclient.utils.URLUtil;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by Jiangzx on 2017/6/23 11:23.
 * 信用卡首页
 */

public class CreditCardIndexBusinessAdapter extends CommonRecyclerAdapter<BusinessClass.TabListBean> {
    private RecycleItemClickedCallback clickedCallback;

    public void setClickedCallback(RecycleItemClickedCallback clickedCallback){
        this.clickedCallback=clickedCallback;
    }

    public CreditCardIndexBusinessAdapter(Context context){
        super(context,null, R.layout.item_image_text_padding_30dp);
    }
    @Override
    public void convert(final CommonRecyclerHolder holder, BusinessClass.TabListBean business) {
        holder.setTextViewText(R.id.tv,business.getName());
        ImageLoaderUtil.displayImageWithPlaceHolder(URLUtil.CBB_IMG_URL+business.getPicture_path(),
                (CircleImageView)holder.getView(R.id.civ),R.mipmap.img_default_square);
        holder.getView(R.id.ll_root).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(clickedCallback!=null){
                    clickedCallback.onRecycleItemClicked(holder.position);
                }
            }
        });
    }
}
